Skip to content

Add psi setup --dry-run for secret state inspection#27

Merged
jdoss merged 2 commits intomasterfrom
feat/setup-dry-run
Apr 9, 2026
Merged

Add psi setup --dry-run for secret state inspection#27
jdoss merged 2 commits intomasterfrom
feat/setup-dry-run

Conversation

@jdoss
Copy link
Copy Markdown
Contributor

@jdoss jdoss commented Apr 9, 2026

Summary

New diagnostic flag psi setup --dry-run that queries the Podman API for every shell-driver secret, cross-references each against state_dir, and compares stored driver opts against what psi install would generate right now. Classifies each secret as:

  • managed — mapping exists in state_dir and driver opts match current psi.conf
  • stale-opts — mapping exists but opts drifted (e.g. token rotated but psi setup has not been re-run)
  • orphaned — no mapping file in state_dir; lookups would return 404

Read-only: does not hit Infisical/HSM, does not mutate Podman state, and surfaces Podman API failures as ProviderError so the CLI prints a clean error instead of a traceback.

Why

Surfaces the silent-drift problem the token rotation work exposed: secrets created manually via podman secret create --driver shell that psi setup never touches, plus secrets left behind by a half-run rotation. We want to see the real state of a production deployment before deciding the shape of any cleanup or schema changes.

Test plan

  • pytest tests/test_dry_run_setup.py — unit tests for _parse_driver_opts (opts extraction from generated TOML), _classify_secrets (managed / stale-opts / orphaned / mixed / missing-name edge cases), and dry_run_setup itself (Podman API failure wrapping and end-to-end report with no filesystem mutations).
  • ruff check / ruff format --check / ty check — clean.
  • Manual test on test server: sudo podman exec psi-secrets psi setup --dry-run and review the report.

jdoss added 2 commits April 9, 2026 11:49
A diagnostic that queries the Podman API for every shell-driver secret,
cross-references each against state_dir, and compares stored driver opts
against what psi install would generate right now. Classifies each
secret as one of:

- managed: mapping exists and driver opts match current psi.conf
- stale-opts: mapping exists but opts drifted (e.g. token rotated but
  psi setup has not been re-run)
- orphaned: no mapping file in state_dir; lookups would 404

Surfaces the silent-drift problem the token rotation work exposed:
secrets created manually via `podman secret create --driver shell` that
psi setup never touches, plus secrets left behind by a half-run
rotation. Read-only — does not hit Infisical/HSM, does not mutate
Podman state, and surfaces Podman API failures as ProviderError so the
CLI prints a clean error instead of a traceback.
@jdoss jdoss merged commit 21937a1 into master Apr 9, 2026
2 checks passed
@jdoss jdoss deleted the feat/setup-dry-run branch April 9, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant